package com.wd.jetpack.demo.paging.api;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * NA<BR>
 *
 * @author W4255
 * @version [V0.0.1, 2021/6/29]
 * @Description: NA
 */
public class RetrofitClient {
    private String BASE_URL = "http://api.apiopen.top/";
    private static RetrofitClient INSTANCE;
    private Retrofit mRetrofit;

    private RetrofitClient() {
        mRetrofit = new Retrofit.Builder().baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .client(getClient()).build();
    }

    private OkHttpClient getClient() {
        return new OkHttpClient.Builder().build();
    }

    public static synchronized RetrofitClient getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new RetrofitClient();
        }
        return INSTANCE;
    }

    public MovieApi getMovieApi() {
        return mRetrofit.create(MovieApi.class);
    }
}
